/// @tags:
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

namespace BlueQuantum {

int const N = 1e5 + 5, ST = 19;

int n, m, e_cnt, dfn_cnt, seg_cnt;
int a[N], heads[N], dep[N], siz[N], maxn[N], dfa[N * 2], vis[N], dsiz[N * 2];
int st[ST][N * 2], lg[N * 2], dfn[N];

struct Edge {
  int v, nxt;
} e[N * 2];

inline void add(int u, int v) {
  e[++e_cnt].v = v, e[e_cnt].nxt = heads[u], heads[u] = e_cnt;
}

void dfs(int u, int fa) {
  st[0][++dfn_cnt] = u;
  dfn[u] = dfn_cnt;
  for (int i = heads[u], v; i; i = e[i].nxt) {
    if ((v = e[i].v) != fa) {
      dep[v] = dep[u] + 1;
      dfs(v, u);
      st[0][++dfn_cnt] = u;
    }
  }
}

inline int cmp(int x, int y) { return dep[x] < dep[y] ? x : y; }

inline void getST() {
  for (int i = 2; i <= dfn_cnt; ++i) lg[i] = lg[i >> 1] + 1;
  for (int i = 1; (1 << i) <= dfn_cnt; ++i) {
    int k = (1 << i);
    for (int j = 1; j + k - 1 <= dfn_cnt; ++j) {
      st[i][j] = cmp(st[i - 1][j], st[i - 1][j + k / 2]);
    }
  }
}

inline int getLCA(int x, int y) {
  x = dfn[x], y = dfn[y];
  if (x > y) swap(x, y);
  int k = lg[y - x + 1];
  return cmp(st[k][x], st[k][y - (1 << k) + 1]);
}

inline int getDIS(int x, int y) { return dep[x] + dep[y] - 2 * dep[getLCA(x, y)]; }

int getRT(int u, int fa, int n_cnt) {
  siz[u] = 1, maxn[u] = 0;
  int rt = 0;
  for (int i = heads[u], v; i; i = e[i].nxt) {
    if (vis[v = e[i].v] == false && v != fa) {
      int vrt = getRT(v, u, n_cnt);
      if (!rt || maxn[vrt] < maxn[rt]) rt = vrt;
      siz[u] += siz[v];
      maxn[u] = max(maxn[u], siz[v]);
    }
  }
  maxn[u] = max(maxn[u], n_cnt - siz[u]);
  if (!rt || maxn[u] < maxn[rt]) rt = u;
  return rt;
}

void divide(int u, int n_cnt) {
  vis[u] = true;
  dsiz[u] = n_cnt;
  for (int i = heads[u], v; i; i = e[i].nxt) {
    if (vis[v = e[i].v] == false) {
      int vsiz = (siz[v] < siz[u]) ? siz[v] : (n_cnt - siz[u]);
      int vrt = getRT(v, u, vsiz);
      dfa[vrt] = u;
      divide(vrt, vsiz);
    }
  }
}

struct Node {
  int ls, rs, sum;
} tr[N * 17 * 15];

struct SegTree {
  int rt;

  void modify(int &x, int l, int r, int pos, int k) {
    if (x == 0) x = ++seg_cnt;
    tr[x].sum += k;
    if (l == r) return;
    int mid = (l + r) >> 1;
    pos <= mid ? modify(tr[x].ls, l, mid, pos, k) : modify(tr[x].rs, mid + 1, r, pos, k);
  }

  int query(int x, int l, int r, int L, int R) {
    if (x == 0) return 0;
    if (L <= l && r <= R) return tr[x].sum;
    int mid = (l + r) >> 1, res = 0;
    if (L <= mid) res += query(tr[x].ls, l, mid, L, R);
    if (mid < R) res += query(tr[x].rs, mid + 1, r, L, R);
    return res;
  }
} T1[N * 2], T2[N * 2];

inline void modify(int x, int val) {
  int cur = x;
  while (cur) {
    int fa = dfa[cur];
    T1[cur].modify(T1[cur].rt, 0, dsiz[cur], getDIS(cur, x), val);
    if (fa) T2[cur].modify(T2[cur].rt, 0, dsiz[fa], getDIS(fa, x), val);
    cur = fa;
  }
}

inline int query(int x, int k) {
  int res = 0, cur = x, lst = 0;
  while (cur) {
    int d = getDIS(x, cur);
    if (d > k) {
      lst = cur;
      cur = dfa[cur];
      continue;
    }
    res += T1[cur].query(T1[cur].rt, 0, dsiz[cur], 0, k - d);
    if (lst) res -= T2[lst].query(T2[lst].rt, 0, dsiz[cur], 0, k - d);
    lst = cur;
    cur = dfa[cur];
  }
  return res;
}

inline void build() {
  dfs(1, 0);
  getST();
  int rt = getRT(1, 0, n);
  divide(rt, n);
  for (int i = 1; i <= n; ++i) modify(i, a[i]);
}

inline int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1, x, y; i < n; ++i) {
    cin >> x >> y;
    add(x, y), add(y, x);
  }
  build();
  int ans = 0;
  for (int i = 1, op, x, y; i <= m; ++i) {
    cin >> op >> x >> y;
    x ^= ans, y ^= ans;
    switch (op) {
      case 0:
        cout << (ans = query(x, y)) << '\n';
        break;
      case 1:
        modify(x, y - a[x]);
        a[x] = y;
    }
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("NodeDividedTree.in", "r", stdin);
  freopen("NodeDividedTree.out", "w", stdout);
#endif
#endif

  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
